package controller;

import context.BaseContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.DTO.CategoryUpCrDTO;
import service.Impl.CategoryServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;
@WebServlet("/admin/category")
public class CategoryCreateController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CategoryServiceImpl service=new CategoryServiceImpl();
        CategoryUpCrDTO dto= (CategoryUpCrDTO) GetJsonUtil.get(req,new CategoryUpCrDTO());
        service.CrCate(dto.getName(),dto.getSort(),dto.getType());
        String json= ResultUtil.getJSON(null);
        resp.getWriter().write(json);
    }
}
